package com.lmx.repoDomain.tmodel;

import java.util.Set;

import javax.persistence.*;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;
import com.lmx.repoDomain.tmodel.business.User;//huibati;
/**
 * 任务表
 */
@Entity
@Table(name = "ccd_task")
@JsonApiResource(type = "task")
public class Task extends BaseEntity {
    private String code;// 任务编码
    private User pubuser;//任务发布人
    private String title;// 任务名称
    private String desc;// 任务描述
    private String iconFile;// 图标文件
    private Short durType;// 任务时间类型，1长期 2短期
    private Short callType;// 任务呼叫类型，1内呼 2外呼
    private Integer beginTime;// 开始时间
    private Integer endTime;// 结束时间
    private Double onlinePay;// 在线时长报酬（单位为小时）
    private Double callinPay;// 接听报酬（单位为每次）
    private Double calloutPay;// 外呼报酬（单位为每次）
    private Double poPay;// 成单报酬（单位为每单）
    private Set<Dicttype> taskTypes;// 任务类型，电销,客服..
    private Dicttype status;//任务状态
//    private Integer csneed;// 需要客服数量
    private Short runstatus;// 进行状态
    private TaskExtend extendIfo;//任务扩展
    private Set<Worktime> worktimes;//任务时间
    private String explicitNum;// 外显号码
    private String explicitApplyFile;//外显号码申请材料路径
    private String verifyFailReason;// 审核失败原因
    private Set<Dicttype> language;// 语言
    private Integer sexPreference; // 性别要求
    private ImsPool imsPool;//总机号码
    private Short settleAccountWay;//结算方式
    private Integer createTime;//创建时间
    private Integer updateTime;//更新时间
    private String remark;//备注

    @Column(name = "code")
    public String getCode() {
        return code;
    }

    public void setCode(final String code) {
        this.code = code;
    }

    @JsonApiToOne
    @JsonApiIncludeByDefault
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @Fetch(FetchMode.JOIN)
    @JoinColumn(name = "ent_id",foreignKey = @ForeignKey(name = "null"))
    public User getPubuser() {
        return pubuser;
    }

    public void setPubuser(User pubuser) {
        this.pubuser = pubuser;
    }

    @Column(name = "title")
    public String getTitle() {
        return title;
    }

    public void setTitle(final String title) {
        this.title = title;
    }

    @Column(name = "descr")
    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    @Column(name = "icon_file")
    public String getIconFile() {
        return iconFile;
    }

    public void setIconFile(final String iconFile) {
        this.iconFile = iconFile;
    }

    @Column(name = "dur_type")
    public Short getDurType() {
        return durType;
    }

    public void setDurType(Short durType) {
        this.durType = durType;
    }

    @Column(name = "call_type")
    public Short getCallType() {
        return callType;
    }

    public void setCallType(Short callType) {
        this.callType = callType;
    }

    @Column(name = "begin_time")
    public Integer getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(Integer beginTime) {
        this.beginTime = beginTime;
    }

    @Column(name = "end_time")
    public Integer getEndTime() {
        return endTime;
    }

    public void setEndTime(Integer endTime) {
        this.endTime = endTime;
    }

    @Column(name = "online_pay")
    public Double getOnlinePay() {
        return onlinePay;
    }

    public void setOnlinePay( Double onlinePay) {
        if(onlinePay == null){
            onlinePay = 0.0;
        }
        this.onlinePay = onlinePay;
    }

    @Column(name = "callin_pay")
    public Double getCallinPay() {
        return callinPay;
    }

    public void setCallinPay(Double callinPay) {
        if(callinPay == null){
            callinPay = 0.0;
        }
        this.callinPay = callinPay;
    }

    @Column(name = "callout_pay")
    public Double getCalloutPay() {
        return calloutPay;
    }

    public void setCalloutPay( Double calloutPay) {
        if(calloutPay == null){
            calloutPay = 0.0;
        }
        this.calloutPay = calloutPay;
    }

    @Column(name = "po_pay")
    public Double getPoPay() {
        return poPay;
    }

    public void setPoPay( Double poPay) {
        if(poPay == null){
            poPay = 0.0;
        }
        this.poPay = poPay;
    }

    @JsonApiToOne
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @JoinColumn(name = "status_id",foreignKey = @ForeignKey(name = "null"))
    @JsonApiIncludeByDefault
    @Fetch(FetchMode.JOIN)
    public Dicttype getStatus() {
        return status;
    }

    public void setStatus(Dicttype status) {
        this.status = status;
    }

/*    @Column(name = "csneed")
    public Integer getCsneed() {
        return csneed;
    }

    public void setCsneed(Integer csneed) {
        this.csneed = csneed;
    }*/

    @Column(name = "runstatus")
    public Short getRunstatus() {
        return runstatus;
    }

    public void setRunstatus(Short runstatus) {
        this.runstatus = runstatus;
    }

    @JsonApiToOne
    @JsonApiIncludeByDefault
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @JoinColumn(name = "extend_info",foreignKey = @ForeignKey(name = "null"))
    @Fetch(FetchMode.JOIN)
    public TaskExtend getExtendIfo() {
        return extendIfo;
    }

    public void setExtendIfo(TaskExtend extendIfo) {
        this.extendIfo = extendIfo;
    }

    @JsonApiToMany
    @JsonApiIncludeByDefault
    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @JoinTable(name = "ccd_task_worktime", joinColumns = {
            @JoinColumn(name = "task_id", nullable = false, updatable = false,foreignKey = @ForeignKey(name = "null")) }, inverseJoinColumns = {
            @JoinColumn(name = "worktime_id", nullable = false, updatable = false,foreignKey = @ForeignKey(name = "null")) })
    @Fetch(FetchMode.JOIN)
    public Set<Worktime> getWorktimes() {
        return worktimes;
    }

    public void setWorktimes(Set<Worktime> worktimes) {
        this.worktimes = worktimes;
    }

    @Column(name = "explicit_num")
    public String getExplicitNum() {
        return explicitNum;
    }

    public void setExplicitNum(String explicitNum) {
        this.explicitNum = explicitNum;
    }

    @Column(name = "verify_fail_reason")
    public String getVerifyFailReason() {
        return verifyFailReason;
    }

    public void setVerifyFailReason(String verifyFailReason) {
        this.verifyFailReason = verifyFailReason;
    }

    @Column(name = "sex_preference")
    public Integer getSexPreference() {
        return sexPreference;
    }

    public void setSexPreference(Integer sexPreference) {
        this.sexPreference = sexPreference;
    }

    @JsonApiToOne
    @JsonApiIncludeByDefault
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @JoinColumn(name = "ims_id",foreignKey = @ForeignKey(name = "null"))
    @Fetch(FetchMode.JOIN)
    public ImsPool getImsPool() {
        return imsPool;
    }

    public void setImsPool(ImsPool imsPool) {
        this.imsPool = imsPool;
    }

    @Column(name = "explicit_apply_file")
    public String getExplicitApplyFile() {
        return explicitApplyFile;
    }

    public void setExplicitApplyFile(String explicitApplyFile) {
        this.explicitApplyFile = explicitApplyFile;
    }

    @Column(name = "settle_account_way")
    public Short getSettleAccountWay() {
        return settleAccountWay;
    }

    public void setSettleAccountWay(Short settleAccountWay) {
        this.settleAccountWay = settleAccountWay;
    }

    @Column(name = "create_time")
    public Integer getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Integer createTime) {
        this.createTime = createTime;
    }

    @Column(name = "update_time")
    public Integer getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Integer updateTime) {
        this.updateTime = updateTime;
    }

    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @JsonApiToMany
    @JsonApiIncludeByDefault
    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @JoinTable(name = "ccd_task_type", joinColumns = {
            @JoinColumn(name = "task_id", nullable = false, updatable = false,foreignKey = @ForeignKey(name = "null")) }, inverseJoinColumns = {
                    @JoinColumn(name = "tasktype_id", nullable = false, updatable = false,foreignKey = @ForeignKey(name = "null")) })
    @Fetch(FetchMode.JOIN)
    public Set<Dicttype> getTaskTypes() {
        return taskTypes;
    }

    public void setTaskTypes(final Set<Dicttype> taskTypes) {
        this.taskTypes = taskTypes;
    }

    @JsonApiToMany
    @JsonApiIncludeByDefault
    @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
    @JoinTable(name = "ccd_task_language", joinColumns = {
            @JoinColumn(name = "task_id", nullable = false, updatable = false,foreignKey = @ForeignKey(name = "null")) }, inverseJoinColumns = {
            @JoinColumn(name = "language_id", nullable = false, updatable = false,foreignKey = @ForeignKey(name = "null")) })
    @Fetch(FetchMode.JOIN)
    public Set<Dicttype> getLanguage() {
        return language;
    }

    public void setLanguage(Set<Dicttype> language) {
        this.language = language;
    }

}